package com.sc.nft.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.meta.component.utils.DateUtil;
import com.sc.nft.annotation.UserLogin;
import com.sc.nft.controller.request.OrderSettlePageRequest;
import com.sc.nft.dto.OrderSettleDTO;
import com.sc.nft.service.ScOrderSettleService;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * <p>
 * 结算单 前端控制器
 * </p>
 *
 * @author PC
 * @since 2024-10-22
 */
@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/pay/orderSettle")
@Api(tags = "用户结算明细")
public class ScOrderSettleController {
    private final ScOrderSettleService scOrderSettleService;


    @ApiOperation(value = "获取用户结算明细列表", notes = "获取用户结算明细列表", httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/getFlowPage", produces = MediaType.APPLICATION_JSON_VALUE)
    @UserLogin
    public Result<IPage<OrderSettleDTO>> getFlowPage(@Valid @RequestBody OrderSettlePageRequest request) {
        String startTime = null;
        if (StringUtils.isNotBlank(request.getStartTime())) {
            startTime= DateUtil.format("yyyy-MM-dd", DateUtil.parseDateTime(request.getStartTime(), "yyyy-MM"));
        }
        return Result.success(scOrderSettleService.getSettlePage(request.getPayChannelEnum(),
                request.getStatusEnum(), request.getPageNo(), request.getPageSize(), startTime));
    }

}
